<?php
use Framework\DiServices\Redis;
use Framework\DiServices\Db;
use Framework\DiServices\ModelsCache;
use Framework\DiServices\ModelsMetadata;
use Framework\DiServices\HttpClient;
use Phalcon\Logger\Adapter\File;
use StarCloud\Library\Config;
use StarCloud\Library\SystemEventsComponent;
use Framework\DiServices\Queue;

$diContainer->setShared('config', new Config($config));
if (isset($config['db'])) {
    $diContainer->setShared('db', new Db($config['db']));
}
if (isset($config['money'])) {
    $diContainer->setShared('money', new Db($config['money']));
}

if (isset($config['queue'])) {
    $diContainer->setShared('queue', new Queue($config['queue']));
}

$diContainer->setShared('redis', new Redis($config['redis']['host'], $config['redis']['port'], $config['redis']['password']));
//$diContainer->setShared('modelsCache', new ModelsCache($config['redis']));
$diContainer->setShared('modelsMetadata', ModelsMetadata::new($config['metadataPath'] ?? ''));
$diContainer->setShared('logger', new File($config['logPath']));

$diContainer->setShared('httpClient', new HttpClient(8, 5));
$diContainer->setShared('sentry', new \Framework\DiServices\Sentry($config['sentry']));
$diContainer->setShared('aliyunSms', new \StarCloud\Library\Sms\AliyunSmsClient($config['aliyunSms']));

$diContainer->setShared('systemEventsComponent', new SystemEventsComponent([
    'ExampleListener' => [
        new \StarCloud\Listeners\ExampleListener(),
        new \StarCloud\Listeners\ExampleListener1(),
        new \StarCloud\Listeners\ExampleListener2(),
    ]
]));
